package com.skycode6.servlet;

import com.skycode6.bean.NewsBean;
import com.skycode6.dao.NewsDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/newsDetail.html")

public class NewsDetailServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String NewsID = req.getParameter("NewsID");
        int newsID = Integer.parseInt(NewsID);
        NewsBean news = (new NewsDao()).getNewsById(newsID);
        req.setAttribute("title",news.getNewsTitle());
        req.setAttribute("content",news.getNewsContent());
        req.getRequestDispatcher("/newsFrontDetail.jsp").forward(req, resp);
    }
}
